package com.net.xpay.admin.filter;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;

import javax.servlet.Filter;

/**
 * Created by net on 2017/10/19.
 * web组件配置 过滤器等
 */
@Configuration
public class WebShardFilterConfig {

    @Bean
    public FilterRegistrationBean filterRegistration() {
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setFilter(ShardContextFilter());
        registration.addUrlPatterns("/*");
        registration.setName("ShardContextFilter");
        registration.setOrder(Ordered.HIGHEST_PRECEDENCE);
        return registration;
    }

    @Bean
    public Filter ShardContextFilter() {
        return new ShardContextFilter();
    }
}
